
import { createRouter, createWebHistory } from 'vue-router';
import Login from "@/components/Login.vue";
import Home from "@/components/Home.vue";
import History from "@/components/History.vue";
import Learning from "@/components/RegionLearning.vue";
import DeepDive from "@/components/DeepDive.vue";
import Policy from "@/components/Policy.vue";
import Register from "@/components/Register.vue";
import ChangePassword from "@/components/ChangePassword.vue";
import Showpage from "@/components/Showpage.vue";
import Auth from "@/components/Auth.vue";
import InheritorListView from "@/components/InheritorListView.vue";
import InheritorDetailView from "@/components/InheritorDetailView.vue";
import CategoryProjectsView from "@/views/CategoryProjectsView.vue";
import ProjectDetailView from "@/views/ProjectDetailView.vue";
import UploadTech from "@/components/UploadTech.vue";
import TechReview from "@/components/TechReview.vue";
// import UploadTech from "@/components/UploadTech.vue";

const routes = [
    {
        path: '/',
        component: Auth, // 使用 Auth.vue 作为父组件
        children: [
            {
                path: '', // 默认子路由，对应登录页
                component: Login,
                name: 'Login',
            },
            {
                path: 'register', // 注册页
                component: Register,
                name: 'Register',
            },
            {
                path: 'change-password', // 修改密码页
                component: ChangePassword,
                name: 'ChangePassword',
            },
        ],
    },
    {
        path: '/home',
        component: Home,
        children: [
            { path: '', component: Showpage },
            { path: 'history', component: History },
            { path: 'learning', component: Learning },
            { path: 'DeepDive', component: DeepDive },
            { path: 'policy', component: Policy },
            { path: 'InheritorListView', component: InheritorListView },

            // 上传相关页面
            { path: 'UploadTech', component: UploadTech },   // ✅ 改为相对路径
            { path: 'TechReview', component: TechReview },   // ✅ 改为相对路径

            { path: 'inheritor/:id', name: 'InheritorDetail', component: InheritorDetailView, props: true },
            { path: 'category/:categoryId/projects', name: 'CategoryProjects', component: CategoryProjectsView, props: true },
            { path: 'category/:categoryId/projects/:projectId', name: 'ProjectDetail', component: ProjectDetailView, props: true }

        ]
    },
    {
        path: '/inheritor/:id',
        name: 'InheritorDetailGlobal',
        component: InheritorDetailView,
        props: true
    }

    // {
    //     path: '/home',
    //     component: Home,
    //     children: [
    //         {
    //             path: '',
    //             component: Showpage,
    //         },
    //         {
    //             path: 'history',
    //             component: History,
    //         },
    //         {
    //             path: 'learning',
    //             component: Learning,
    //         },
    //         {
    //             path: 'DeepDive',
    //             component: DeepDive,
    //         },
    //         {
    //             path: 'policy',
    //             component: Policy,
    //         },
    //         // 传承人
    //         {
    //             path:'InheritorListView',
    //             component: InheritorListView,
    //         },
    //
    //         // 上传
    //
    //         {
    //             path: '/UploadTech',
    //             component: UploadTech,
    //         },
    //         // 管理员审核
    //         {
    //             path: '/TechReview',
    //             component: TechReview,
    //         },
    //         {
    //             path: '/inheritor/:id',
    //             name: 'InheritorDetail',
    //             component: InheritorDetailView,
    //             props: true
    //         },
    //         // // 非遗项目
    //         {
    //             path: '/category/:categoryId/projects',
    //             name: 'CategoryProjects',
    //             component: CategoryProjectsView,
    //             props: true
    //         },
    //         {
    //             path: '/category/:categoryId/projects/:projectId',
    //             name: 'ProjectDetail',
    //             component: ProjectDetailView,
    //             props: true
    //         },
    //     ],
    // },
];


const router = createRouter({
    history: createWebHistory(),
    routes,
});

export default router;
